

#include <iostream>
#include <stdio.h>
#include <vector>

#include "BirdApplication.h"

//#include "/usr/include/opencv/cv.h"
//#include "/usr/include/opencv/cvaux.h"
//#include "/usr/include/opencv/highgui.h"

#//include<opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

JNIEXPORT void JNICALL Java_BirdApplication_funzione(JNIEnv *, jobject) {

    cv::Mat img;
    cv::Mat img_th;

    //--- load img
    int i = 5;
    char filename[200];
    sprintf(filename, "img/birds%02d.jpg", i);
    //fprintf(stderr, "\nciao\n");
    img = cv::imread(filename);
    cv::imshow("orig", img);

    //--- rgb2gray
    cv::Mat img_gray(img.size(), CV_8U, cv::Scalar(255));
    cv::cvtColor(img, img_gray, CV_RGB2GRAY);
    cv::imshow("gray", img_gray);

    //--- load threshold
    cv::Mat img_bin(img.size(), CV_8U, cv::Scalar(255));
    cv::threshold(img_gray, img_bin, 40, 255, cv::THRESH_BINARY);
    cv::imshow("bin", img_bin);

    //--- blob detection
    std::vector< std::vector<cv::Point> > contours;
  
    //cv::findContours(img_bin, contours, CV_RETR_EXTERNAL,  CV_CHAIN_APPROX_NONE);
            // retrieve the external contours
            // all pixels of each contours
    
    // Draw black contours on a white image
 //  cv::Mat img_res(img.size(), CV_8U, cv::Scalar(255));
 //   cv::drawContours(img_res, contours,
  //          -1, // draw all contours
   //         cv::Scalar(0), // in black
    //        2); // with a thickness of 2
//cv::imshow("res", img_res);


    cv::waitKey(0);
    return;
}


